﻿using Amazon;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ZenHR.AttData.Package.Util
{
    class AwsS3Helper
    {

        public static string  AwsUpload(string file_key,string file_path)
        {
            AWSConfigs.AWSRegion = "cn-northwest-1";
            var debuggstr = new StringBuilder();
            var client = new Amazon.S3.AmazonS3Client(Utility.GetConfig("AWS_AKeyID"), Utility.GetConfig("AWS_SAKey"));
      

            //上传的文件路径
            var uploadkey = file_key; //"CLOCKDATA/test.config";
            var pb = client.PutObject(new Amazon.S3.Model.PutObjectRequest()
            {
                //文件在本地的位置
                FilePath = file_path, //@"C:\Temp\Application publish\ZENHR\HRWinJobService\ZenHR_JobTask.exe.config",
                BucketName = "wd-interface-nx-test",
                Key = uploadkey
            });

            //wd-interface-nx-test  wd-interface-nx-prd
            var url = client.GetPreSignedURL(new Amazon.S3.Model.GetPreSignedUrlRequest() { Key = uploadkey, BucketName = "wd-interface-nx-test", Expires = DateTime.Now.AddDays(7) });

            return url;

        }

                 
    }
}
